package cn.jobstart.spider.downloader;

import cn.jobstart.spider.downloader.request.HtmlRequest;
import us.codecraft.webmagic.Page;
import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.Task;
import us.codecraft.webmagic.downloader.Downloader;
import us.codecraft.webmagic.selector.PlainText;

/**
 * @author sunke
 * @version 1.0
 * @Description html标签 下载
 * @date 2023-10-18 15:30
 */
public class HtmlTagDownloader implements Downloader {


    /**
     * Downloads web pages and store in Page object.
     *
     * @param request request
     * @param task    task
     * @return page
     */
    @Override
    public Page download(Request request, Task task) {
        Page page = new Page();
        page.setUrl(new PlainText(request.getUrl()));
        page.setRequest(request);
        page.setDownloadSuccess(true);
        page.setRawText(((HtmlRequest) request).getHtml());
        return page;
    }

    /**
     * Tell the downloader how many threads the spider used.
     *
     * @param threadNum number of threads
     */
    @Override
    public void setThread(int threadNum) {


    }
}
